{% extends "base.html" %}

{% block title %}{{ point.name }} - 监控详情{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col">
            <h2>{{ point.name }} - 监控详情</h2>
            <p>
                <i class="fas fa-map-marker-alt"></i> {{ point.location }}<br>
                <small class="text-muted">{{ point.description }}</small>
            </p>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title mb-0">最近24小时数据</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>时间</th>
                                    <th>溶解氧(mg/L)</th>
                                    <th>pH值</th>
                                    <th>温度(℃)</th>
                                    <th>氨氮(mg/L)</th>
                                    <th>浊度(NTU)</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for item in data %}
                                <tr>
                                    <td>{{ item.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}</td>
                                    <td>{{ "%.2f"|format(item.dissolved_oxygen) }}</td>
                                    <td>{{ "%.2f"|format(item.ph_value) }}</td>
                                    <td>{{ "%.1f"|format(item.temperature) }}</td>
                                    <td>{{ "%.2f"|format(item.ammonia_nitrogen) }}</td>
                                    <td>{{ "%.2f"|format(item.turbidity) }}</td>
                                    <td>
                                        <form action="{{ url_for('monitor.delete_data', data_id=item.id) }}" method="POST" class="d-inline" onsubmit="return confirm('确定要删除这条数据吗？');">
                                            <button type="submit" class="btn btn-danger btn-sm">
                                                <i class="fas fa-trash"></i>
                                            </button>
                                        </form>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 